package com.example.demo.Controller;

import com.example.demo.Common.User;
import com.example.demo.Hyperv;
import com.example.demo.Server.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/User")
public class UserController {
    
    Hyperv hyperv = new Hyperv();

    @Autowired
    UserService userService;

    //用户登录接口
    @PostMapping("/login")
    public boolean login(@RequestBody User user){
        String account = user.getAccount();
        String password = user.getPassword();
        System.out.println(account);
        System.out.println(password);
        if (userService.login(account,password) != null) {
            System.out.println("登录成功");
            return true;
        }else {
            System.out.println("账户或密码错误");
            return false;
        }
    }


    @GetMapping("/hyperv")
    public void Hyper() {
        String vmName = "TestVM";
        String vmPath = "D:\\Hyper-v\\vhdx";
        int memory = 1024;
        int diskSize = 10;
        String isoPath = "D:\\CentOS-DVD\\Win11_23H2_Chinese_Simplified_x64v2.iso";
        String Message = hyperv.vmCreate(vmName, vmPath, memory, diskSize,isoPath);
        System.out.println(Message);
    }

}
